
let { CleanWebpackPlugin } = require('clean-webpack-plugin')
const base = require('./webpack.base')
const { merge } = require('webpack-merge')
const webpack = require('webpack')
let miniCss = require('css-minimizer-webpack-plugin')
let miniJS = require('terser-webpack-plugin')
module.exports = merge(base, {
  mode: 'production',
  plugins: [
    new webpack.DefinePlugin({
      // 定义一些编译阶段全局变量
      BASEURL: "'https://baidu.com'",
    }),
  ],
  optimization: {
    minimizer: [
      new miniCss(),
      new miniJS()
    ],
    splitChunks: {
      minSize: 100,
      cacheGroups: {
        qqq: {
          filename: "jq_la.js",
          test: /jquery|lodash/,
          chunks: 'initial'
        }
      }
    }
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: 'babel-loader',
        exclude: /node_modules/ // node_modules中的内容不需要使用babel-loader处理
      }
    ]
  }
})